package com.ruoyi.mail.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaMallShopInformation;
import com.ruoyi.system.service.IJiajiaMallShopInformationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商城店铺信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@Controller
@RequestMapping("/mall/shop")
public class JiajiaMallShopInformationController extends BaseController
{
    private String prefix = "mall/shop";

    @Autowired
    private IJiajiaMallShopInformationService jiajiaMallShopInformationService;

    @RequiresPermissions("system:shop:view")
    @GetMapping()
    public String information()
    {
        return prefix + "/shop";
    }

    @RequiresPermissions("system:shop:view")
    @GetMapping("/childShop")
    public String childShop()
    {
        return prefix + "/childShop";
    }

    /**
     * 查询商城店铺信息列表
     */
    @RequiresPermissions("system:shop:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaMallShopInformation jiajiaMallShopInformation)
    {
        startPage();
        List<JiajiaMallShopInformation> list = jiajiaMallShopInformationService.selectJiajiaMallShopInformationList(jiajiaMallShopInformation);
        return getDataTable(list);
    }

    /**
     * 导出商城店铺信息列表
     */
    @RequiresPermissions("system:shop:export")
    @Log(title = "商城店铺信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaMallShopInformation jiajiaMallShopInformation)
    {
        List<JiajiaMallShopInformation> list = jiajiaMallShopInformationService.selectJiajiaMallShopInformationList(jiajiaMallShopInformation);
        ExcelUtil<JiajiaMallShopInformation> util = new ExcelUtil<JiajiaMallShopInformation>(JiajiaMallShopInformation.class);
        return util.exportExcel(list, "商城店铺信息数据");
    }

    /**
     * 新增商城店铺信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商城店铺信息
     */
    @RequiresPermissions("system:shop:add")
    @Log(title = "商城店铺信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaMallShopInformation jiajiaMallShopInformation)
    {
        return toAjax(jiajiaMallShopInformationService.insertJiajiaMallShopInformation(jiajiaMallShopInformation));
    }

    /**
     * 修改商城店铺信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaMallShopInformation jiajiaMallShopInformation = jiajiaMallShopInformationService.selectJiajiaMallShopInformationById(id);
        mmap.put("jiajiaMallShopInformation", jiajiaMallShopInformation);
        return prefix + "/edit";
    }

    /**
     * 修改保存商城店铺信息
     */
    @RequiresPermissions("system:shop:edit")
    @Log(title = "商城店铺信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaMallShopInformation jiajiaMallShopInformation)
    {
        return toAjax(jiajiaMallShopInformationService.updateJiajiaMallShopInformation(jiajiaMallShopInformation));
    }

    /**
     * 删除商城店铺信息
     */
    @RequiresPermissions("system:shop:remove")
    @Log(title = "商城店铺信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaMallShopInformationService.deleteJiajiaMallShopInformationByIds(ids));
    }
}
